﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VerficationsWPF.HWControls;

namespace VerficationsWPF.Models
{
    /// <summary>
    /// ColorBlocksModel.xaml 的交互逻辑
    /// </summary>
    [Info(Importance = 10, IsDisplayed = true)]
    public partial class ColorfulBlocksModel : BaseModel
    {
        /// <summary>
        /// 创建各种颜色的Lable,用以展示。
        /// </summary>
        /// <param name="lblColor">要创建的Label的颜色</param>
        /// <returns></returns>
        public Control Createlbl(Color lblColor)
        {
            // Label lbl = new Label();
            RoundedBoxItem lbl = new RoundedBoxItem();
            lbl.Margin = new Thickness(10, 10, 10, 10);
            lbl.Height = 180;
            lbl.Width = 180;
            SolidColorBrush scb = new SolidColorBrush(lblColor);
            lbl.Background = scb;
            return lbl;
        }
        /// <summary>
        /// 初始化WrapPanel，其内容是各色标签。
        /// </summary>
        public void IniWrapPanel()
        {
            Type t = typeof(Colors);
            PropertyInfo[] pInfo = t.GetProperties();
            foreach (PropertyInfo pi in pInfo)
            {
                Color c = (Color)ColorConverter.ConvertFromString(pi.Name);
                var lbl = Createlbl(c);
                //lbl.Content = pi.Name;
                wp.Children.Add(lbl);
            }
        }
        /// <summary>
        /// 初始化窗体，以合理的尺寸显示各种颜色。
        /// </summary>
        public void IniWindow()
        {
            // this.Title = "ColorPresentation";
            // this.ResizeMode = ResizeMode.NoResize;
            // this.Height = 600;
            // this.Width = 820;
            Content = wp;
        }

        public ColorfulBlocksModel()
        {
            InitializeComponent();
            IniWindow();
            IniWrapPanel();
            Title = "颜色测试";
            Description = "本示例通过动态生成颜色，每种颜色生成一个Label，然后洄以WrapPanel中进行呈现";
        }
    }
}
